<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$return['status']=$this->hetong_status;
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['usename'])){
		$params['usename like']='%'.trim($_RQ['usename']).'%';
		$return['params']['usename']=$_RQ['usename'];
	}
	if(!empty($_RQ['mobile'])){
		$params['mobile like']='%'.trim($_RQ['mobile']).'%';
		$return['params']['mobile']=$_RQ['mobile'];
	}
	if(!empty($_RQ['status'])){
		$params['status']=trim($_RQ['status']);
		$return['params']['status']=intval($_RQ['status']);
	}
    $orderby='id desc';
	$total='';
	$return['list']=pdo_getslice('jy_aihire_hetonglist',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$item){
		$item['member']=pdo_get('jy_aihire_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['memberid']),array('realname','nickname','mobile'));
		$item['fadititle']=pdo_getcolumn('jy_aihire_fadi',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['fadiid']),'title');
		$item['hetpltitle']=pdo_getcolumn('jy_aihire_hetongtpl',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['hetplid']),'title');
	}
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'电子合同'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(	
			array('name'=>'username','title'=>'签署人姓名','type'=>'string'),
			array('name'=>'mobile','title'=>'手机号','type'=>'string'),
			array('name'=>'codesn','title'=>'证件号码','type'=>'string'),
			array('name'=>'fadititle','title'=>'发放地','type'=>'string'),
			array('name'=>'hetpltitle','title'=>'合同模板名称','type'=>'string'),
			array('name'=>'createtime','title'=>'签署日期','type'=>'time'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		),'action'=>array(
			array('type'=>'modal','op'=>'look','title'=>'详情'),
		)),
		'search'=>array(
			array('name'=>'usename','width'=>10,'title'=>'签署人姓名','type'=>'string'),
			array('name'=>'mobile','width'=>10,'title'=>'手机号','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='look'){
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('jy_aihire_hetonglist',array('id'=>$id));
		$item['fadititle']=pdo_getcolumn('jy_aihire_fadi',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['fadiid']),'title');
		$item['hetpltitle']=pdo_getcolumn('jy_aihire_hetongtpl',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['hetplid']),'title');
	}else{
		$item=array();
	}
	$item['images']=json_decode($item['images'],true);
    $return['item']=$item;
	$htmls=array(
		'type'=>'look',
		'desc'=>'电子合同详情',
		'look'=>array(
			array('name'=>'usename','title'=>'签署人姓名','type'=>'string'),
			array('name'=>'mobile','title'=>'手机号','type'=>'string'),
			array('name'=>'codesn','title'=>'证件号码','type'=>'string'),
			array('name'=>'fadi','title'=>'发放地','type'=>'string'),
			array('name'=>'hetplid','title'=>'合同模板名称','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
			array('name'=>'images','title'=>'合同内容','type'=>'images'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){

	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_aihire_hetonglist',array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_aihire_hetonglist',array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
}
?>